<?php

namespace app\admin\model;

class   Inventory extends Base
{

    // 表名
    protected $name = 'bal_inventory';


    //产品
//    public function material()
//    {
//        return $this->belongsTo("Material", 'fk_bdl_bd_material', 'fnumber');
//    }
//    public function mater()
//    {
//        return $this->belongsTo("Material", 'fk_bdl_bd_material', 'fnumber',[],'LEFT')->setEagerlyType(0);
//    }



//    public function mateib()
//    {
//        return $this->hasOne("Material", 'fnumber', 'fk_bdl_bd_material',[],'LEFT')->setEagerlyType(0);
//    }
//    //表面
//    public function surface()
//    {
//        return $this->hasone("Surface",'fnumber', 'fk_bdl_bd_surface',[],'LEFT')->setEagerlyType(0);
//    }
//    //材质
//    public function texture()
//    {
//        return $this->hasone("Texture",'fnumber', 'fk_bdl_bd_texture',[],'LEFT')->setEagerlyType(0);
//    }

//    public function textureo()
//    {
//        return $this->belongsTo("Texture",'fk_bdl_bd_texture', 'fnumber')->setEagerlyType(1);
//    }
//
//    //表面
//    public function sur()
//    {
//        return $this->belongsTo('Surface', 'fk_bdl_bd_surface', 'fnumber',[],'LEFT')->setEagerlyType(1);
//    }

    //表面
    public function surfaceone()
    {
        return $this->belongsTo("Surface",'fk_bdl_bd_surface', 'id');
    }
    //材质
    public function textureone()
    {
        return $this->belongsTo("Texture",'fk_bdl_bd_texture', 'id');
    }
    public function mateia()
    {
        return $this->belongsTo("Material", 'fk_bdl_bd_material', 'id');
    }


    //表面
    public function surfacefirs()
    {
        return $this->hasOne("Surface", 'id','fk_bdl_bd_surface',[],"LEFT")->setEagerlyType(0);
    }

    //材质
    public function texturefirs()
    {
        return $this->hasOne("Texture", 'id','fk_bdl_bd_texture',[],"LEFT")->setEagerlyType(0);

    }
    public function materialfirs()
    {
        return $this->hasOne("Material", 'id','fk_bdl_bd_material',[],"LEFT")->setEagerlyType(0);
    }

    //属性值
    public function inventoryentry()
    {
        return $this->hasMany("Inventoryentry",'id', 'id');
    }
    //属性名称和值
    public function inventoryentryvalue()
    {
        return $this->belongsToMany("Matprop",'bal_inventoryentry','fk_bdl_matpropid','id');

    }





}
